//
//  YXLJifenMallHeadView.m
//  MyNewProject
//
//  Created by 于兴雷 on 2019/2/16.
//  Copyright © 2019年 sun. All rights reserved.
//

#import "YXLJifenMallHeadView.h"

@implementation YXLJifenMallHeadView

-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.image = [UIImage imageNamed:@"myBgView"];
        self.userInteractionEnabled = YES;
        [self initView];
    }
    
    return self;
}

-(void)initView
{

    UILabel *promptLab = [UILabel new];
    promptLab.textAlignment = NSTextAlignmentCenter;
    promptLab.text = @"可用积分";
    promptLab.font = [UIFont systemFontOfSize:14];
    [self addSubview:promptLab];
    promptLab.sd_layout
    .centerXEqualToView(self)
    .topSpaceToView(self, 10)
    .heightIs(15)
    .widthIs(200);

    UILabel *jifenNumLab = [UILabel new];
    jifenNumLab.font = SKFONT_Medium(34);
    jifenNumLab.textAlignment = NSTextAlignmentCenter;
    jifenNumLab.text = @"0";
    [self addSubview:jifenNumLab];
    self.jifenNumLab = jifenNumLab;
    jifenNumLab.sd_layout
    .centerXEqualToView(self)
    .topSpaceToView(promptLab, 15)
    .heightIs(25)
    .widthIs(200);
    

    UIButton *jifenDetailBtn = [UIButton new];
    [jifenDetailBtn setTitle:@"积分详情" forState:UIControlStateNormal];
    [jifenDetailBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    jifenDetailBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    jifenDetailBtn.layer.cornerRadius = 15;
    jifenDetailBtn.layer.borderWidth = 1;
    jifenDetailBtn.layer.borderColor = [[UIColor blackColor] CGColor];
    [self addSubview:jifenDetailBtn];
    self.jifenDetailBtn = jifenDetailBtn;
    jifenDetailBtn.sd_layout
    .topSpaceToView(jifenNumLab, 20)
    .leftSpaceToView(self, SCREEN_WIDTH/2.0-120)
    .heightIs(30)
    .widthIs(100);
    
    UIButton *jifenHistoryBtn = [UIButton new];
    [jifenHistoryBtn setTitle:@"兑换记录" forState:UIControlStateNormal];
    [jifenHistoryBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    jifenHistoryBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    jifenHistoryBtn.layer.cornerRadius = 15;
    jifenHistoryBtn.layer.borderWidth = 1;
    jifenHistoryBtn.layer.borderColor = [[UIColor blackColor] CGColor];
    [self addSubview:jifenHistoryBtn];
    self.jifenHistoryBtn = jifenHistoryBtn;
    jifenHistoryBtn.sd_layout
    .topSpaceToView(jifenNumLab, 20)
    .leftSpaceToView(jifenDetailBtn, 40)
    .heightIs(30)
    .widthIs(100);
    
    //[self setupAutoHeightWithBottomView:jifenHistoryBtn bottomMargin:20];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
